/*
 * GUIObject.h
 *
 *  Created on: 20/10/2009
 *      Author: marcos
 */

#ifndef GUIOBJECT_H_
#define GUIOBJECT_H_

#include <string>
#include "util/MathUtils.h"
#include "gui/Surface.h"

namespace gui {
class GUIObjectDrawer;
// 158 pixeles es el ancho de una calle, aprox 10 mts
const static int METERS_TO_PIXEL_RATIO = 2;
int toPixels(double v);

class GUIObject {
public:
	// GUIObject(GUIObjectDrawer* drawer, RGBColor baseColor = BLACK);
	/* Constructor para crear con imagen de archivo y color transparente */
	GUIObject(GUIObjectDrawer* drawer, std::string filename, RGBColor transparentColor = BLUE);
	GUIObject(GUIObjectDrawer* drawer, RGBColor baseColor);

	virtual ~GUIObject();

	// Getters
	virtual RGBColor getBaseColor() { return this->baseColor; }

	virtual int getRColor();

	virtual int getGColor();

	virtual int getBColor();

	int getXPos();

	int getYPos();

	int getWidth();

	int getHeight();

	virtual std::string getTexture();

	virtual RGBColor getTextureTransparentColor() { return this->textureTransparentColor; }

	virtual int getTextureTransparentColorR();

	virtual int getTextureTransparentColorG();

	virtual int getTextureTransparentColorB();

	virtual bool getTextureStrech();

	int getExpectedLength();

	virtual bool getTextureHasTransparentColor();

	virtual double getRotation();

	virtual Surface* asSurface();

protected:
	// Setters
	virtual void setBGColor(RGBColor baseColor);

//	virtual void setTexture(std::string texture, int expectedLength = -1);
//
//	virtual void setTexture(std::string texture, RGBColor transparentColor, bool noRepeat);

	virtual void setRotation(double rotation);

	void setCenterInMeters(double x, double y);
	void setSizeInMeters(double w = -1.0, double h = -1.0);
	void setSize(int w = -1, int h = -1);
	void setCenter(int x, int y);

private:
	void redrawSurface();
	int xPos;
	int yPos;
	int expectedLength;
	std::string texture;
	RGBColor textureTransparentColor;
	RGBColor baseColor;
	bool textureStrech;
	bool hasTransparentColor;
	double rotation;
	GUIObjectDrawer* drawer;
	Surface* surface;

};

}

#include "gui/util/GUIObjectDrawer.h"

#endif /* GUIOBJECT_H_ */
